# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=cryptography
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=3.3.1
pkgrel=1
pkgdesc="A package designed to expose cryptographic recipes and primitives to Python developers (mingw-w64)"
url='https://pypi.org/project/cryptography/'
license=('Apache')
arch=('any')
depends=("${MINGW_PACKAGE_PREFIX}-python-cffi"
         "${MINGW_PACKAGE_PREFIX}-python-pyasn1"
         "${MINGW_PACKAGE_PREFIX}-python-idna"
         "${MINGW_PACKAGE_PREFIX}-python-asn1crypto")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-six")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest-runner"
              #"${MINGW_PACKAGE_PREFIX}-python-iso8601"
              "${MINGW_PACKAGE_PREFIX}-python-pretend"
              #"${MINGW_PACKAGE_PREFIX}-python-cryptography-vectors"
              #"${MINGW_PACKAGE_PREFIX}-python-hypothesis"
              "${MINGW_PACKAGE_PREFIX}-python-pytz")
source=(https://pypi.io/packages/source/c/cryptography/${_realname}-${pkgver}.tar.gz)
sha256sums=('7e177e4bea2de937a584b13645cab32f25e3d96fc0bc4a4cf99c27dc77682be6')

prepare() {
  cd ${srcdir}
  cp -r ${_realname}-${pkgver} python-build-${CARCH}
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd ${srcdir}/python-build-${CARCH}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
